Extension point operation
Documentation
string string
Contribution Descriptors
- Class: org.nuxeo.automation.scripting.internals.ScriptingOperationDescriptor
Existing Contributions
Contributions are presented in the same order as the registration order on this extension point. This order is displayed before the contribution name, in brackets.
-
<extension point="operation" target="org.nuxeo.automation.scripting.internals.AutomationScriptingComponent"> <scriptedOperation id="javascript.PictureVisionDefaultMapper"> <inputType>Document</inputType> <outputType>Document</outputType> <category>javascript</category> <description/> <script><![CDATA[function run(input, params) { var blob = Picture.GetView(input, {'viewName': 'Medium'}); blob = VisionOp(blob, { 'features': ['LABEL_DETECTION'], 'maxResults': 5, 'outputVariable': 'annotations' }); var annotations = ctx.annotations; if (annotations===undefined || annotations.length===0) return; var textAndLabels = annotations[0]; // build tag list var labels = textAndLabels.getClassificationLabels(); if (labels !== undefined && labels !== null && labels.length>0) { var tags = []; for(var i=0;i<labels.length;i++) { var label = labels[i]; var tag = label.getText(); if (tag ===undefined || tag ===null) continue; tags.push(tag.replace(/[^A-Z0-9]+/ig,'+')); } input = Services.TagDocument(input, {'tags': tags }); } return input; }]]></script> </scriptedOperation> <scriptedOperation id="javascript.VideoVisionDefaultMapper"> <inputType>Document</inputType> <outputType>Document</outputType> <category>javascript</category> <description/> <script><![CDATA[function run(input, params) { var storyboard = input['vid:storyboard']; var blobs = []; var index; var tags = []; for (index=0;index<storyboard.length;index++) { var blob = storyboard[index].content; VisionOp(blob, { 'features': ['LABEL_DETECTION'], 'maxResults': 5, 'outputVariable': 'annotations' }); var annotations = ctx.annotations; if (annotations===undefined || annotations.length===0) return; // build tag list var textAndLabels = annotations[0]; var labels = textAndLabels.getClassificationLabels(); if (labels === undefined || labels === null || labels===0) continue; for(var j=0;j<labels.length;j++) { var label = labels[j]; var tag = label.getText(); if (tag ===undefined || tag ===null) continue; tags.push(tag.replace(/[^A-Z0-9]+/ig,'+')); tags.push(label.getText().replace(/\s/g,'+')); } } input = Services.TagDocument(input, {'tags': tags }); return input; }]]></script> </scriptedOperation> </extension>
-
<extension point="operation" target="org.nuxeo.automation.scripting.internals.AutomationScriptingComponent"> <scriptedOperation id="javascript.FilterTemplatesByType"> <inputType>document</inputType> <outputType>documents</outputType> <category>javascript</category> <description>Filter templates according to the type of a given input document.</description> <script><![CDATA[ function run(input, params) { return Repository.Query(null, { 'query': 'select * from Document where ecm:mixinType = "Template" AND ecm:currentLifeCycleState != "deleted" AND tmpl:applicableTypes IN ( "all", "' + input['type'] + '")' }); } ]]></script> </scriptedOperation> <scriptedOperation id="javascript.RenderPdf"> <inputType>document</inputType> <outputType>blob</outputType> <category>javascript</category> <param name="templateName" type="string"/> <param name="attach" type="boolean"/> <param name="templateData" type="string"/> <description>Render a document with a given template and converts it to PDF.</description> <script><![CDATA[ function run(input, params) { var blob = TemplateProcessor.Render(input, { 'templateName': params.templateName, 'attach': params.attach || false, 'templateData': params.templateData || null }); return Blob.RunConverter(blob, {'converter': 'any2pdf'}); } ]]></script> </scriptedOperation> </extension>